<template>
  <el-dialog
    :visible.sync="$store.state.dias.courierPic.show"
    width="500px"
    center
    class="courierPic-add"
    title="已发货"
    >
    <main>
      <div v-for="(item, index) in modelData" :key="index" class="box">
        <span class="title">{{item.label}}：</span>
        <Upload v-if="item.isUpload" @success="success" :keys="item.prop" />
        <span v-else-if="item.isLabel">{{info[item.prop]}}</span>
      </div>
    </main>
    <div slot="footer" class="dialog-footer">
      <el-button type="info" class="w120" @click="$store.state.dias.courierPic.show = false">取 消</el-button>
      <el-button type="success" class="w120" @click="submit">提 交</el-button>
    </div>
  </el-dialog>
</template>
<script>
import Upload from '@/components/upload/uploadImg'
export default {
  props:['id'],
  components: {Upload},
  name: "",
  data() {
    return {
      modelData:[
        {prop:"logisticsNum",label:"上传签收单",isUpload:true,checked:true},
        {prop:"notice",label:"提示",isLabel:true},
      ],
      info:{
        logisticsNum:"",
        notice:"上传之后不能修改",
      }
    };
  },
  methods: {
    success(val){
      this.info[val.key]=val.data
      console.log(val,this.info);
      
    },
    submit(){
      let params = {
        logisticsNum:this.info.logisticsNum,
        id:this.id
      }
      
      if(_g.checkParams(this.modelData,params))return
      _g.apiPost('sellerOrder/delivered.do',params).then(res=>{
        if(res!==undefined){
          _g.toMessage(res)
          if(res.status==0){
            this.$emit('flash')
            this.$store.state.dias.courierPic.show=false
          }
        }
      })
    }
  },
  created() {}
};
</script>
<style lang="scss" scoped>
.courierPic-add {
  font-size: 14px;
  main{
    padding-right: 20px;
    div.box{
      display: flex;
      line-height: 36px;

      .title{
        display: inline-block;
        min-width: 75px;
        margin-right: 10px;
        text-align: right;
      }
      .btn{
        padding: 0 5px;
        font-size: 12px;
        border-radius: 0;
        margin-left: 10px;
        min-width: 100px;
      }
    }
    div:nth-last-of-type(1){
      margin-bottom: 0;
    }
  }
  .w120{
    width: 150px;
  }
  .dialog-footer{
    padding-bottom: 20px;
  }
}
</style>